﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using IL2SWAUtilities;

namespace IL2SWA
{
    public partial class MissionDetails : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
             

                DataTable resultsMissionDetails = new DataTable();
                resultsMissionDetails = IL2SWAUtilities.DataAccess.RunSP("[RepMissionDetailsGet]", new string[] { }, new object[] { });
                MissionDetailsList.DataSource = resultsMissionDetails;
                MissionDetailsList.DataTextField = resultsMissionDetails.Columns[1].ToString();
                MissionDetailsList.DataValueField = resultsMissionDetails.Columns[0].ToString();
                MissionDetailsList.DataBind();
                SelectedMission.Text = "";
                SelectedMission.Visible = false;
                MissionDetailsLabel.Text = "";
                MissionDetailsLabel.Visible = false;

                if (Request.QueryString["MissionName"] != null)
                {
                    MissionDetailsList.SelectedIndex = MissionDetailsList.Items.IndexOf(MissionDetailsList.Items.FindByText(Request.QueryString["MissionName"]));
                    MissionDetailsList_SelectedIndexChanged(MissionDetailsList, null);
                }

            }
        }


        protected void MissionDetailsList_SelectedIndexChanged(object sender, EventArgs e)
        {   
             // PlayerHighLevelView
            SelectedMission.Text = "Mission Data For " + MissionDetailsList.SelectedItem.ToString();
            SelectedMission.Font.Bold = true;
            SelectedMission.Visible = true;
            MissionDetailsLabel.Text = "Mission Details";
            MissionDetailsLabel.Visible = true;

            IL2SWAUtilities.UIControls.BindGrid(MissionHighLevelView, "RepMissionDetailsGetByID", new string[] { "@MissionID" }, new object[] { MissionDetailsList.SelectedValue });
            IL2SWAUtilities.UIControls.BindGrid(MissionHighLevelViewBlueRed, "RepMissionDetailsBlueRedGetByID", new string[] { "@MissionID" }, new object[] { MissionDetailsList.SelectedValue });
            IL2SWAUtilities.UIControls.BindGrid(MissionActionDetails, "RepMissionActionDetailsByID", new string[] { "@MissionID" }, new object[] { MissionDetailsList.SelectedValue });
          
                      
            
        }
    }
}